import React from "react";
import { useSelector } from "react-redux";
import type { RootState } from "../../store";
type propsType = {
    auth: string;
    children: string | JSX.Element | JSX.Element[] | (() => JSX.Element);
}

const AuthCheck = (props: propsType) => {
    const { auth, children } = props;
    const permissions = useSelector((state: RootState) => state.userInfo.info.permissions);
    // 权限检测
    if (permissions && !permissions.includes(auth)) {
        return null;
    }
    return children;
}
export default AuthCheck